package com.jdjc.subject.infra.rpc;

import com.jdjc.auth.api.UserFeignService;
import com.jdjc.auth.entity.AuthUserDTO;
import com.jdjc.auth.entity.Result;
import com.jdjc.subject.infra.basic.entity.UserInfo;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class UserRPC {
    @Resource
    private UserFeignService userFeignService;

    public UserInfo getUserInfo(String userName){
        AuthUserDTO authUserDTO=new AuthUserDTO();
        authUserDTO.setUserName(userName);
        Result<AuthUserDTO> result = userFeignService.getUserInfo(authUserDTO);
        UserInfo userInfo=new UserInfo();
        if (!result.getSuccess()){

            return userInfo;
        }
        AuthUserDTO userDTO = result.getData();
        userInfo.setUserName(userDTO.getUserName());
        userInfo.setNickName(userDTO.getNickName());
        userInfo.setCreateUserAvatar(userDTO.getAvatar());
        return userInfo;
    }


}
